package com.travelcloud.module.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.travelcloud.framework.utils.RedisService;
import com.travelcloud.module.product.entity.ProductInfo;
import com.travelcloud.module.product.mapper.ProductInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Zee
 * @since 2020年6月19日
 */
@Service
@Slf4j
public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, ProductInfo>{

    @Resource
    private ProductInfoMapper productInfoMapper;
    @Autowired
    private RedisService redis;

    /**
     * redis
     *
     * @param productName
     * @return
     */

    @Cacheable(value = "key1", key = "'getByLikeName:' + #productName", unless = "#result == null")
    public List<ProductInfo> getByLikeName(String productName) {
        log.info("日志");
        return productInfoMapper.getByLikeName(productName);
    }

}
